<template>
  <div class="cash" ref="cash">
    <div class="cash-wrapper">
      <v-header class="cash-header"></v-header>
      <div class="cash-body">
        <personal-title class="cash-title" title="提現"></personal-title>
        <div class="cash-container">
          <div class="cash-module">
            <span class="cash-number">{{chexCount}}</span>
            <span class="cash-unit">CHEX</span>
          </div>
          <el-button round class="cash-btn">提現</el-button>
          <span class="self-account">我的账户</span>
          <span class="diamond"></span>
        </div>
        <div class="personal-module qrcode-module">
          <p class="qrcode-description">下載APP，順暢進行交易和提現</p>
          <div class="qrcode-container">
            <div class="ios-qrcode">
              <div class="qrcode-content">
                <img :src="iosQrcode" class="ios-qrcode-img" @touchstart="iosQrcodeTouchstart" @touchend="iosQrcodeTouchend" alt="">
                <p class="qrcode-tip">IOS下載</p>
              </div>
            </div>
            <div class="android-qrcode">
              <div class="qrcode-content">
                <img :src="androidQrcode" class="android-qrcode-img" @touchstart="androidQrcodeTouchstart" @touchend="androidQrcodeTouchend" alt="">
                <p class="qrcode-tip">Android下載</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Header from '@/components/Header'
import PersonalTitle from '@/components/PersonalTitle'
import { mapGetters } from 'vuex'
export default {
  name: 'cash',
  data () {
    return {
      iosQrcode: './static/img/ios-qrcode.jpg',
      androidQrcode: './static/img/android-qrcode.jpg',
      chexCount: this.$route.params.chexCount
    }
  },
  computed: {
    ...mapGetters([
      'token',
      'uid'
    ])
  },
  beforeRouteEnter (to, from, next) {
    if (from.path !== '/personal') {
      next(false)
    }
    next()
  },
  mounted () {
    this.$nextTick(() => {
      this._initScroll()
    })
  },
  methods: {
    _initScroll () {
      this.cashScroll = new this.$BScroll(this.$refs.cash, {
        click: true,
        preventDefaultException: {
          className: /((^|\s)ios-qrcode-img(\s|$))|(^|\s)android-qrcode-img(\s|$)/
        }
      })
    },
    iosQrcodeTouchstart () {
      this.iosQrcode = './static/img/ios-qrcode.jpg'
      this.androidQrcode = './static/img/ios-qrcode.jpg'
    },
    iosQrcodeTouchend () {
      this.androidQrcode = './static/img/android-qrcode.jpg'
    },
    androidQrcodeTouchstart () {
      this.androidQrcode = './static/img/android-qrcode.jpg'
      this.iosQrcode = './static/img/android-qrcode.jpg'
    },
    androidQrcodeTouchend () {
      this.iosQrcode = './static/img/ios-qrcode.jpg'
    }
  },
  components: {
    vHeader: Header,
    PersonalTitle
  }
}
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
.cash-wrapper{
  padding: 37px 49px 57px;
}
.cash-header{
  margin-bottom: 64px;
}
.cash-body{
  box-sizing: border-box;
  padding: 44px 32px 38px;
  background: #fff;
  .cash-title{
    margin-bottom: 37px;
  }
  .cash-container{
    position: relative;
    display: flex;
    box-sizing: border-box
    width: 100%;
    padding: 58px 40px 66px 22px;
    margin: 0 auto 47px;
    border-radius: 8px;
    background: linear-gradient(to right bottom, #EAAB00, #FFCA00);
    font-size: 0;
    .cash-module{
      flex: 1;
      height: 66px;
      color: rgba(255,255,255,1);
      .cash-number{
        display: inline-block;
        vertical-align: bottom;
        font-size: 66px;
        line-height: 66px;
      }
      .cash-unit{
        display: inline-block;
        vertical-align: bottom;
        font-size: 22px;
        line-height: 22px;
      }
    }
    .cash-btn{
      flex: 0 0 142px;
      width: 142px;
      height: 51px;
      margin-top: 12px;
      background: rgba(255,255,255,0);
      border-radius: 26px;
      font-size: 28px;
      color: rgba(255,255,255,1);
    }
    .self-account{
      box-sizing: border-box;
      position: absolute;
      right: 25px;
      top: 18px;
      width: 160px;
      height: 34px;
      padding-left: 43px;
      line-height: 34px;
      font-size:28px;
      color:rgba(255,255,255,1);
      background: url("../assets/images/coin.png") no-repeat;
    }
    .diamond{
      position: absolute;
      right: 6px;
      bottom: 0;
      width: 121px;
      height: 80px;
      background: url("../assets/images/diamond.png") no-repeat;
      background-size: cover;
    }
  }
}
.personal-module{
  position: relative;
  &:after {
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    border-top: 1px solid rgba(220,220,220,1); /*no*/
    content: '';
  }
  .personal-title{
    margin-bottom: 32px;
  }
}
@media (-webkit-min-device-pixel-ratio: 1.5),(min-device-pixel-ratio: 1.5) {
  .personal-module{
    &:after {
      -webkit-transform: scaleY(0.7);
      transform: scaleY(0.7);
    }
  }
}
@media (-webkit-min-device-pixel-ratio: 2),(min-device-pixel-ratio: 2) {
  .personal-module{
    &:after{
      -webkit-transform: scaleY(0.5);
      transform: scaleY(0.5);
    }
  }
}
.qrcode-module{
  padding: 61px 41px 104px;
  .qrcode-description{
    height: 26px;
    margin-bottom: 73px;
    font-size: 26px;
    color: rgba(102,102,102,1);
    line-height: 26px;
    text-align: center;
  }
  .qrcode-container{
    display: flex;
    width: 100%;
    .ios-qrcode{
      flex: 1;
      margin-right: 32px;
    }
    .android-qrcode{
      flex: 1;
    }
  }
  .qrcode-content{
    width: 100%;
    margin: 0 auto;
    text-align: center;
    font-size: 0;
    .ios-qrcode-img, .android-qrcode-img{
      width: 223px;
      height: 215px;
      margin-bottom: 14px;
    }
    .qrcode-tip{
      font-size:24px;
      color:rgba(102,102,102,1);
      line-height:24px;
      text-align: center;
    }
  }
}
</style>
